package com.sh.redis.suanfa;

import com.sh.entity.dto.User;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class QuChong {

    public static void main(String[] args) {
        List<User> a = new ArrayList<>();
        a.add(new User(1, "aa"));
        a.add(new User(1, "bb"));
        a.add(new User(1, "cc"));
        a.add(new User(3, "dd"));


        List<User> b = new ArrayList<>();
        Set<Integer> set = new HashSet<>();
        for(User u : a){
            if(set.add(u.getId())){
                b.add(u);
            }
        }
        System.out.println(b.size());
    }
}
